﻿<%--
 *  @Author: Kevinfan
 *  Date:    4/11/2011
 *
 *  Copyright (C) 2000 - 2012 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>
<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>
<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<%
  //init param
  Category cat = Category.getInstance("jsp.PharmacyPurchaseTypein");
  String strModuleName = "TDR";
  String privilegeCode = "A0404";
  String contextPath = request.getContextPath();
%>
<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>
<html>
<head>
<title>PharmacyPurchaseTypein</title>
<PageFlow:CheckPageFlow pageName="p_datatypein"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath%>/css/cn/main.css" type="text/css">
<link rel="stylesheet" href="<%=contextPath%>/css/autocomplete.css" type="text/css">
<script language="JavaScript" src="<%=contextPath%>/css/cn/script.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/ScriptLib.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/FuncLib.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/keyFunction.js"></script>
<script type="text/javascript" src="<%=contextPath%>/js/spellcode/yahoo-dom-event.js"></script>
<script type="text/javascript" src="<%=contextPath%>/js/spellcode/animation-min.js"></script>
<script type="text/javascript" src="<%=contextPath%>/js/spellcode/autocomplete.js"></script>
<script type="text/javascript" src="<%=contextPath%>/js/spellcode/spellCodeAutoComplete.js"></script>
<script type="text/javascript" src="ZopSaleOrderNew.js"></script>
<%@ include file="/inc/NewCalendar.inc" %>
<script language="JavaScript"><!--
<%
	String year = ((Integer)pageContext.getAttribute("year")).toString();
	String month = ((Integer)pageContext.getAttribute("month")).toString();
	String result = (String)pageContext.getAttribute("result");
	String optionvalue = (String)pageContext.getAttribute("endday2");
	Vector detail = (Vector)pageContext.getAttribute("detail");
	Vector totalsummary = (Vector)pageContext.getAttribute("totalsummary");
	java.util.Calendar cal = java.util.Calendar.getInstance();      
	int day = cal.get(Calendar.DAY_OF_MONTH);
	String periodflag = "false";
	int j = 5;
    if("Y".equals(optionvalue)){
             periodflag = "true";}
             
	if(totalsummary==null)totalsummary = detail;
	if(totalsummary.size()!=0)j=totalsummary.size();
	if(totalsummary.size()==0 && (result.equals("false") || periodflag.equals("false")))j=0;
	if(totalsummary.size()==0 && (month.equals("1") && periodflag.equals("true")))j=5;
%>
function page_save(q){
  window.setTimeout(function(){
    var numrows = parseInt($("input[name='numrows']").val());
    //alert(numrows);
	var list=document.getElementsByTagName("input");
	for(var i=0;i<list.length && list[i];i++){
      str = list[i].name;
      if(str.length>11 && str.substr(0,11)=="description"){
      	continue;
      } 
      //alert(list[i].value);
      if(list[i].type=="text"){
         if(list[i].value=="" || list[i].value==null || list[i].value=="--助记码--" || list[i].value=="--快速代码--"){
          alert("请填写完整数据！");
          list[i].focus();
          return;
         }
      }
	}
	for(var i=0;i<numrows;i++){
	 if(eval('document.cform.doctorid'+i).value == null || eval('document.cform.doctorid'+i).value == "null" || isEmpty(eval('document.cform.doctorid'+i).value)){
	   /*
	   eval('document.cform.doccode'+i).value="";
	   eval('document.cform.doctorname'+i).value="";
	   eval('document.cform.hosdeptname'+i).value="";
	   eval('document.cform.prodcodecontainer'+i).value="";
	   */
	   setDoctor(i,"&nbsp;","","")
	   alert("医生不能为空！");
	   eval('document.cform.doccode'+i).focus();
	   return;
	 }  
	 if(eval('document.cform.productid'+i).value == null || eval('document.cform.productid'+i).value == "null" || isEmpty(eval('document.cform.productid'+i).value)){
       page_setProduct(i,"","","","");
	   alert("产品不能为空！");
	   eval('document.cform.productcode'+i).focus();
	   return;
	 }
	 var salesqty=(eval('document.cform.salesqty'+i)).value;
	 if(salesqty < 0 || salesqty == null){
	    alert("医生的处方数量不能为空并要大于0");
	    return;
	 }
	}
	if(q==1)
		document.cform.strstatus.value = "10";
	else
		document.cform.strstatus.value = "40";
	document.cform.actionname.value = "saved";
    document.cform.target = "_self";
    isRunning = true;
	document.cform.submit();
	},3500);
}

var index;
function setDoctor(id,name,code,hosdeptname)
{
	document.getElementById("tr"+index).cells[3].innerHTML = name;
	document.getElementById("tr"+index).cells[7].innerHTML = "&nbsp;"+hosdeptname;
	document.getElementById("doccode" + index).value = code;
  	eval('document.cform.doctorid'+index).value = id;
	eval('document.cform.doctorcode'+index).value = code;
	eval('document.cform.doctorname'+index).value = name;
	eval('document.cform.hosdeptname'+index).value = hosdeptname;
}

function page_setHospital(id,name,code,level)
{	
	//document.cform.prodid.value = id;
	eval('document.cform.spellitemcode'+index).value = name;
	document.getElementById("pharmacycode" +index).value = code;
	if(level=="")level = "&nbsp;"
	document.getElementById("tr" +index).cells[6].innerHTML = "&nbsp;"+level;
	if(eval('document.cform.dealerid'+index).value != id){
		eval('document.cform.dealerid'+index).value = id;
		document.getElementById("tr"+index).cells[3].innerHTML = "&nbsp;";
		document.getElementById("tr"+index).cells[7].innerHTML = "&nbsp;";
		document.getElementById("doccode" + index).value = "";
	}
	eval('document.cform.dealercode'+index).value = code;
	eval('document.cform.dealername'+index).value = name;
	eval('document.cform.level'+index).value = level;
	page_department(index);
	hiddenFrm();
}

function page_setProduct(id,code,name,price,spec)
{	
	eval('document.cform.spellproditemcode'+index).value = name;
	document.getElementById("prodcode" + index).value = code;
	if(spec=="")spec = "&nbsp;"
	document.getElementById("tr" + index).cells[8].innerHTML = spec;
	if(price=="")price = "&nbsp;"
	document.getElementById("tr" + index).cells[9].innerHTML = price;
	eval('document.cform.productid'+index).value = id;
	eval('document.cform.productcode'+index).value = code;
	eval('document.cform.productname'+index).value = name;
	if(spec != "&nbsp;")
	eval('document.cform.specifications'+index).value = spec;
	if(price != "&nbsp;")
	eval('document.cform.price'+index).value = price;
	hiddenFrm();
	page_doSum(eval('document.cform.price'+index),index);
	setTimeout("page_department("+index+");",2000);
}

var isHidden;
function frm_select(e,flag,i){
	isHidden = "block";
	var _target = getPosition(e);
    var _obj = document.getElementById("summaryfrm");
    _obj.style.left = _target.x -2;
    _obj.style.top = _target.y +  e.clientHeight - 74;
    _obj.style.height="250px";
    _obj.style.width="530px";
    _obj.style.zIndex = 5000;
    _obj.style.display = "block";
	index = i;
	var strUrl = "";
	if(flag==1){
		strUrl = "HospitalSelectPop.jsp?maxitem=8&<%= OvalTools.randomURL() %>";
	}else if(flag==2){
	   if(isEmpty(eval('document.cform.dealerid'+i).value)){
	    alert("请先选择医院！");
	    return;
	   }
		hospitalid = eval("document.cform.dealerid"+i).value;
		strUrl = "DoctorSelectPop.jsp?maxitem=8&hospitalid="+hospitalid+"&<%= OvalTools.randomURL() %>";
	}else if(flag==3){
		_obj.style.height="300px";
	  if(isEmpty(eval('document.cform.dealerid'+i).value)){
	    alert("请先选择医院！");
	    return;
	   }
	  if(isEmpty(eval('document.cform.doctorid'+i).value)){
	    alert("请先选择医生！");
	    return;
	   }
	   var year = document.cform.year.value;
	   var month = document.cform.month.value;
		hospitalid = eval("document.cform.dealerid"+i).value;
		doctorid = eval("document.cform.doctorid"+i).value;
		strUrl = "ProdSelectPop.jsp?maxitem=10&hospitalid="+hospitalid+"&doctorid="+doctorid+"&year="+year+"&month="+month+"&mflag=1"+"&<%= OvalTools.randomURL() %>";
	}
    document.summaryfrm.location.href = strUrl;
}
function getPosition(e) {
        var left = 0;
        var top = 0;
        while (e.offsetParent) {
            left += e.offsetLeft + (e.curentStyle? (parseInt(e.curentStyle.borderLeftWidth).NaN0()):0);
            top += e.offsetTop + (e.curentStyle ? (parseInt(e.curentStyle.borderTopWidth)).NaN0() : 0);
            e = e.offsetParent;
        }
        left += e.offsetLeft + (e.curentStyle ? (parseInt(e.curentStyle.borderLeftWidth)).NaN0() : 0);
        top += e.offsetTop + (e.curentStyle ? (parseInt(e.curentStyle.borderTopWidth)).NaN0() : 0);
        return {x:left, y:top};
}
function closeItemSelect(evt)
{
	var _obj = document.getElementById("summaryfrm");
	if(isHidden == "block"){
		isHidden = "none";
	}else{
		_obj.style.display = "none";
	}
	evt = evt || window.event;
        var _target = evt.target || evt.srcElement;
        if (!_target.getAttribute("Author") && _target != inputObj && _target != targetObj) {
            getObjById("Calendar").style.display = "none";
            getObjById("CalendarFrm").style.display = "none";
        }
}

function hiddenFrm(){
	document.getElementById("summaryfrm").style.display = "none";
}

document.onclick=closeItemSelect;   

function page_doSum(obj,idx) 
{
		if(obj.value=="" || obj.value=="null" || obj.value=="&nbsp")return;
		if (!isNaN(Number(obj.value))) 
		{
			var num1 = Number(eval('document.cform.salesqty'+idx).value);
			if(num1==0)return;
			if(eval('document.cform.price'+idx).value!=""){
				var num3 = Number(eval('document.cform.price'+idx).value);
				money = num1 * num3;
				if(isNaN(Number(money)))money = "&nbsp";
				eval('document.cform.amount'+idx).value = money;
			}
		}else{
			alert("请输入正确的数值！");
			obj.focus();
		}
	 //var re = /^[\.\d]+$/, flag;
	var re=/^\+?[1-9]\d*$/,flag;
    flag = re.test(obj.value);
    if(flag ==false){
    alert("不能输入带小数点的数字！");}
}   

function page_checkNum(obj) 
{
		if(obj.value=="")return;
		if (isNaN(Number(obj.value))){
			alert("请输入正确的数值！");
			obj.focus();
		}
}	

function page_delOneDetail(id,flag) {
    var numrows = parseInt(document.getElementById("numrows").value);
    var tableobj = document.getElementById("oTBody");
    var trobj = document.getElementById("tr" + id);
    var onedetailid = "";
	if(flag==1){
		var onedetailid = document.getElementById("tdr_formal_salesdataid" + id).value;
    }
    tableobj.deleteRow(trobj.rowIndex - 1);
    for (var i = 0; i < oTBody.rows.length; i++)
    {
        oTBody.rows[i].cells[0].innerHTML = parseInt(i) + 1;
    }
	if(onedetailid!=""){
		var datahandler = new DataHandler();
		datahandler.add_params("onedetailid", onedetailid, "integer");
		datahandler.add_job("j_delformalsalesdata");
		datahandler.runDataHandler();
	}
	if ( oTBody.rows.length == 0){	 
		addNewRow(1);
	}
	document.getElementById("numrows").value=numrows-1;
}	

function page_getInfoByCode(obj,flag,idx){
	code = obj.value;
	if(code=="")code=-1;
	var  datahandler = new  DataHandler();
	datahandler.add_params("code" , code, 'String');
	if(flag==1){
	datahandler.add_params("querytype" , "hospital", 'String');
	datahandler.getResultFromHashMap("onehash","hospitalid","document.cform.dealerid"+idx);
	datahandler.getResultFromHashMap("onehash","hospitalname","document.cform.dealername"+idx);
	datahandler.getResultFromHashMap("onehash","hospitalcode","document.cform.dealercode"+idx);
	datahandler.getResultFromHashMap("onehash","hospitallevelname","document.cform.level"+idx);
	}else if(flag==2){
	datahandler.add_params("querytype" , "doctor", 'String');
	hospitalid = eval('document.cform.dealerid'+idx).value;
    if(hospitalid == null || hospitalid == "null" || isEmpty(hospitalid)){
	    alert("请先选择医院！");
	    return;
	}
	datahandler.add_params("hospitalid" ,hospitalid, 'Integer');
	datahandler.getResultFromHashMap("onehash","doctorid","document.cform.doctorid"+idx);
	datahandler.getResultFromHashMap("onehash","doctorcode","document.cform.doctorcode"+idx);
	datahandler.getResultFromHashMap("onehash","doctorname","document.cform.doctorname"+idx);
	datahandler.getResultFromHashMap("onehash","hosdeptname","document.cform.hosdeptname"+idx);
	}else{
	
	datahandler.add_params("querytype" , "prod", 'String');
	hospitalid = eval('document.cform.dealerid'+idx).value;
	doctorid = eval('document.cform.doctorid'+idx).value;
	if(hospitalid == null || hospitalid == "null" || isEmpty(hospitalid)){
	    alert("请先选择医院！");
	    return;
	}
    if(doctorid == null || doctorid == "null" || isEmpty(doctorid)){
	    alert("请先选择医生！");
	    return;
	}
	datahandler.add_params("hospitalid" ,hospitalid, 'Integer');
	datahandler.add_params("doctorid" ,doctorid, 'Integer');
	datahandler.getResultFromHashMap("onehash","prodid","document.cform.productid"+idx);
	datahandler.getResultFromHashMap("onehash","prodcode","document.cform.productcode"+idx);
	datahandler.getResultFromHashMap("onehash","prodname","document.cform.productname"+idx);
	datahandler.getResultFromHashMap("onehash","unitprice","document.cform.price"+idx);
	datahandler.getResultFromHashMap("onehash","spec","document.cform.specifications"+idx);
	}
	datahandler.add_job("j_selectspellcn");
	datahandler.runDataHandler();
	
	if(flag==2)timer="2000";else timer="1800"; 
	setTimeout("page_setValue("+idx+","+flag+");",timer);
 }

function page_setValue(idx,flag){
    if(flag==1){
      var dealerid=eval('document.cform.dealerid'+idx).value;
       if(dealerid == null || dealerid == "null" || isEmpty(doctorid)){
		alert("没有符合条件的医院！");
		return;
	   }
	}else if(flag==2){
	   var doctorid=eval('document.cform.doctorid'+idx).value;
	   if(doctorid == null || doctorid == "null" || isEmpty(doctorid)){
		alert("没有符合条件的医生！");
		return;
	   }
	}else if(flag==3 && isEmpty(eval('document.cform.productid'+idx).value)){
		alert("没有符合条件的产品！");
		return;
	}
	//alert(eval('document.cform.productid'+idx).value);
	if(flag==1){
	    dealername = eval('document.cform.dealername'+idx).value;
        dealercode=  eval('document.cform.dealercode'+idx).value;
	    level = eval('document.cform.level'+idx).value;
	    dealerid=eval('document.cform.dealerid'+idx).value;
	   	eval('document.cform.spellitemcode'+idx).value = dealername;
	    document.getElementById("pharmacycode" +idx).value = dealercode;
	    if(level=="")level = "&nbsp;"
	    document.getElementById("tr" +idx).cells[6].innerHTML = "&nbsp;"+level;
	  if(eval('document.cform.dealerid'+idx).value != dealerid){
		 eval('document.cform.dealerid'+idx).value = dealerid;
		 document.getElementById("tr"+idx).cells[3].innerHTML = "&nbsp;";
		 document.getElementById("tr"+idx).cells[7].innerHTML = "&nbsp;";
		 
		 //document.getElementById("tr" + idx).cells[9].innerHTML ="&nbsp;";
		 //document.getElementById("doccode" + idx).value = "";
	     }
	    eval('document.cform.dealercode'+idx).value = dealercode;
	    eval('document.cform.dealername'+idx).value = dealername;
	    eval('document.cform.level'+idx).value = level;
	}
    if(flag==2){
	   var doctorid = eval('document.cform.doctorid'+idx).value;
	   var doctorcode = eval('document.cform.doctorcode'+idx).value;
	   var doctorname = eval('document.cform.doctorname'+idx).value;
	   var hosdeptname = eval('document.cform.hosdeptname'+idx).value;
	   if(doctorid == null || doctorid == "null" || isEmpty(doctorid)){
		eval('document.cform.doctorid'+idx).value = id;
		document.getElementById("tr"+idx).cells[3].innerHTML = "&nbsp;";
		document.getElementById("tr"+idx).cells[7].innerHTML = "&nbsp;";
		document.getElementById("doccode" + idx).value = "";
	    }else{
	     document.getElementById("tr"+idx).cells[3].innerHTML = doctorname;
	     document.getElementById("tr"+idx).cells[7].innerHTML = "&nbsp;"+hosdeptname;
	     document.getElementById("doccode" + idx).value = doctorcode;
  	     eval('document.cform.doctorid'+idx).value = doctorid;
	     eval('document.cform.doctorcode'+idx).value = doctorcode;
	     eval('document.cform.doctorname'+idx).value = doctorname;
	     eval('document.cform.hosdeptname'+idx).value = hosdeptname;
	   }
	   eval('document.cform.productid'+idx).value = "";
	   eval('document.cform.productcode'+idx).value = "";
	   eval('document.cform.productname'+idx).value = productname;
	}
    if(flag==3){
	   var productid = eval('document.cform.productid'+idx).value;
	   var productcode = eval('document.cform.productcode'+idx).value;
	   var productname = eval('document.cform.productname'+idx).value;
	   var price = eval('document.cform.price'+idx).value;
	   var specifications = eval('document.cform.specifications'+idx).value;
	   eval('document.cform.spellproditemcode'+idx).value = productname;
	   document.getElementById("prodcode" + idx).value = productcode;
	   if(specifications=="")specifications = "&nbsp;"
	   document.getElementById("tr" + idx).cells[8].innerHTML = specifications;
	   if(price=="")price = "&nbsp;"
	   document.getElementById("tr" + idx).cells[9].innerHTML = price;
	   eval('document.cform.productid'+idx).value = productid;
	   eval('document.cform.productcode'+idx).value = productcode;
	   eval('document.cform.productname'+idx).value = productname;
	   if(specifications != "&nbsp;")
	   eval('document.cform.specifications'+idx).value = specifications;
	   if(price != "&nbsp;")
	   eval('document.cform.price'+idx).value = price;
	}
	
	//alert("success");
	

	/*eval('document.cform.spellproditemcode'+index).value = name;
	document.getElementById("prodcode" + index).value = code;
	if(spec=="")spec = "&nbsp;"
	document.getElementById("tr" + index).cells[8].innerHTML = spec;
	if(price=="")price = "&nbsp;"
	document.getElementById("tr" + index).cells[9].innerHTML = price;
	eval('document.cform.productid'+index).value = id;
	eval('document.cform.productcode'+index).value = code;
	eval('document.cform.productname'+index).value = name;
	if(spec != "&nbsp;")
	eval('document.cform.specifications'+index).value = spec;
	if(price != "&nbsp;")
	eval('document.cform.price'+index).value = price;
	hiddenFrm();
	page_doSum(eval('document.cform.price'+index),index);*?
	
    /*eval('document.cform.spellitemcode'+index).value = name;
	document.getElementById("pharmacycode" +index).value = code;
	if(level=="")level = "&nbsp;"
	document.getElementById("tr" +index).cells[6].innerHTML = "&nbsp;"+level;
	if(eval('document.cform.dealerid'+index).value != id){
		eval('document.cform.dealerid'+index).value = id;
		document.getElementById("tr"+index).cells[3].innerHTML = "&nbsp;";
		document.getElementById("tr"+index).cells[7].innerHTML = "&nbsp;";
		document.getElementById("doccode" + index).value = "";
	}
	eval('document.cform.dealercode'+index).value = code;
	eval('document.cform.dealername'+index).value = name;
	eval('document.cform.level'+index).value = level;
	
	document.getElementById("tr"+idx).cells[3].innerHTML ="&nbsp;"+eval('document.cform.doctorname'+idx).value;
	
	if(eval('document.cform.hosdeptname'+idx).value=="null")eval('document.cform.hosdeptname'+idx).value="&nbsp";
	document.getElementById("tr"+idx).cells[7].innerHTML = "&nbsp;"+eval('document.cform.hosdeptname'+idx).value;
	
	if(eval('document.cform.dealername'+idx).value!="null" && eval('document.cform.dealername'+idx).value!=""){
		if(eval('document.cform.spellitemcode'+idx).value != eval('document.cform.dealername'+idx).value){
		eval('document.cform.spellitemcode'+idx).value = eval('document.cform.dealername'+idx).value;
		document.getElementById("tr"+idx).cells[3].innerHTML = "&nbsp;"+eval('document.cform.doctorname'+idx).value;
		document.getElementById("tr"+idx).cells[7].innerHTML = "&nbsp;"+eval('document.cform.hosdeptname'+idx).value;
		}
	}else{
		eval('document.cform.spellitemcode'+idx).value = "";
	}	
	if(eval('document.cform.level'+idx).value=="null")eval('document.cform.level'+idx).value="&nbsp";
	document.getElementById("tr"+idx).cells[6].innerHTML = "&nbsp;"+eval('document.cform.level'+idx).value;
	if(eval('document.cform.productname'+idx).value!="null" && eval('document.cform.productname'+idx).value!="")
	eval('document.cform.spellproditemcode'+idx).value = eval('document.cform.productname'+idx).value;
	if(eval('document.cform.specifications'+idx).value=="null")eval('document.cform.specifications'+idx).value="&nbsp";
	document.getElementById("tr"+idx).cells[8].innerHTML = "&nbsp;"+eval('document.cform.specifications'+idx).value;
	if(eval('document.cform.price'+idx).value=="null")eval('document.cform.price'+idx).value="&nbsp";
	document.getElementById("tr"+idx).cells[9].innerHTML = "&nbsp;"+eval('document.cform.price'+idx).value;
	*/
	page_doSum(eval('document.cform.price'+idx),idx);
	page_department(idx);
}

function clearQik(obj,str){
        if(Trim(obj.value) == '--'+str+'--'){
            obj.value = '';
        }else{
            selectText(obj);
        }
}

function reQik(obj,str){
        if(Trim(obj.value) == ''){
            obj.value = '--'+str+'--';    
        }
}

function page_department(idx){
	orgid = eval('document.cform.dealerid'+idx).value;
	employeeid = eval('document.cform.maker'+idx).value;
	var productid = eval('document.cform.productid'+idx).value;
	if(orgid == "" || orgid == "null"){
		document.getElementById("tr"+idx).cells[10].innerHTML = "&nbsp;";
		return;
	}
	var  datahandler = new  DataHandler();
	datahandler.add_params("querytype" , 2, 'Integer');
	datahandler.add_params("orgid" , orgid, 'Integer');
	datahandler.add_params("employeeid" , employeeid, 'Integer');
	datahandler.add_params("productid" , productid, 'Integer');
	datahandler.getResultFromHashMap("onehash","productgroupid","document.cform.productgroupid"+idx);
	datahandler.getResultFromHashMap("onehash","productgroupcode","document.cform.productgroupcode"+idx);
	datahandler.getResultFromHashMap("onehash","productgroupname","document.cform.productgroupname"+idx);
	datahandler.add_job("j_selectgroup");
	datahandler.runDataHandler();
	setTimeout("page_setGroupValue("+idx+");","250");
 }
 
function page_setGroupValue(idx){
	if(eval('document.cform.productgroupname'+idx).value!="null" && eval('document.cform.productgroupname'+idx).value!="")
	document.getElementById("tr"+idx).cells[10].innerHTML = eval('document.cform.productgroupname'+idx).value;
}

function page_selectbyDate(){
	var year = document.cform.year.value;
	var month = document.cform.month.value;
	self.location="<%=contextPath%>/tdr/datatypein/DoctorSalesTypein.jsp?<%= OvalTools.randomURL() %>&businesstype=170&year="+year+"&month="+month;
}
--></script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" scroll="no" class="yui-skin-sam">
<iframe id="reloadHandler" name="reloadHandler" style="display:none"></iframe>
<form name="cform" method="post" action="<%=contextPath%>/Dispatcher">
<input type="hidden" name="pagename" value="p_datatypein">
<input type="hidden" name="actionname">
<input type="hidden" name="strstatus">
<custom:hidden property="businesstype"/>
<input type="hidden" name="numrows" value="<%=totalsummary.size()==0?5:totalsummary.size() %>">
<%
		HashMap employeeinfo = (HashMap)pageContext.getAttribute("employeeinfo");
			String salesmanid = "";
			String salesman = "";                
			String salesmanname = "";            
			String areacode = "";                 
			String areaname = "";               
			String parentemployeeid = "";         
			String parentemployeecode =  "";      
			String parentemployeename = "";         
			String cityname =  "";                
			String citycode = "";
			String parentareacode = "";
	    	String parentareaname = "";
			String deptid = "";
			String deptcode = "";
			String deptname = "";
		if(employeeinfo.size() !=0){
			salesmanid = ((Integer)employeeinfo.get("userid")).toString();
			salesman = (String)employeeinfo.get("employeecode");                
			salesmanname = (String)employeeinfo.get("employeename");            
			areacode = "";                  
			areaname = "";           
			parentemployeeid = ((Integer)employeeinfo.get("parentemployeeid")).toString();         
			parentemployeecode =  (String)employeeinfo.get("parentemployeecode");      
			parentemployeename = (String)employeeinfo.get("parentemployeename");         
			cityname = "";              
			citycode ="";  
			parentareacode = "";  
			parentareaname = "";  
			deptid = "";  
			deptcode ="";  
			deptname = "";  
		}
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="overflow:scroll">
<tr>
<td>
<table width="100%" cellspacing="0" cellpadding="0">
    <tr>
        <td class="title-big-b-center">
            <table width="100%" cellspacing="0">
                <tr>
		        	<td style="width:40px;" class="td_right"><%=label.getLabelName("L_Year1") +  label.getLabelName("L_Colon") %></td>
		        	<td style="width:50px;" class="td_left"><custom:selectdic property="year" dictType="Years" command="notnull" value="<%=year %>" label="L_Year1"/></td>
		        	<td style="width:40px;" class="td_right"><%=label.getLabelName("L_Month") +  label.getLabelName("L_Colon") %></td>
		        	<td style="width:50px;" class="td_left"><custom:selectdic property="month" dictType="Months" command="notnull" value="<%=month %>" label="L_Month"/></td>
	                <td style="width:50px;"><a onclick="page_selectbyDate()"><img src="<%=contextPath%>/images/cn/ss.png" border="0" ></a></td>
	                <td>
					<%	
						if((month.equals("1") || result.equals("true")) && periodflag.equals("true")){
					%>
					<script>
							document.getElementById("mydiv").style.height = "360px";
					</script>
					<table width="100%" cellspacing="0">
						<tr>
							<td class="td_right">
								<custom:button type="1" label="L_Save" imgsrc="Modify.gif" border="0" onclick="page_save(1);" style="width:55"/>
							</td>
						</tr>
					</table>
					<%}%>
					</td>
                </tr>
                <tr>
                    <td class="title-big-b-center" colspan="6">医生处方量录入</td>
                </tr> 
            </table>
        </td>
    </tr>
     <tr>
        <td class="title-big-b-center">
            <table width="100%" cellspacing="0" border="1" bordercolorlight="#999999" bordercolordark="#FFFFFF" align="left" style="margin-left:-3;">
                <tr>
					<td class="td-text" width="20%"><%= label.getLabelName("L_YearN") + label.getLabelName("L_Colon")%></td>
                    <td width="30%">&nbsp;<%=year%></td>
                    <td class="td-text" width="20%"><%= label.getLabelName("L_MonthN") + label.getLabelName("L_Colon")%></td>
                    <td width="30%">&nbsp;<%=month%></td>
                </tr>
                <!-- 
				<tr> 
                    <td class="td-text"><%= label.getLabelName("L_RegionOffice") + label.getLabelName("L_Colon")%></td>
                    <td>&nbsp;<%=parentareaname%></td>  
					<td class="td-text"><%= label.getLabelName("L_City") + label.getLabelName("L_Colon")%></td>
                    <td>&nbsp;<%=cityname%></td>
                </tr>
                 -->
                <tr>
                    <td class="td-text"><%= label.getLabelName("L_RegionManager") + label.getLabelName("L_Colon")%></td>
                    <td>&nbsp;<%=parentemployeename%></td>
					<td class="td-text"><%= label.getLabelName("L_SalesRep") + label.getLabelName("L_Colon")%></td>
                    <td>&nbsp;<%=salesmanname%></td>
                    
                </tr>
                
            </table>
        </td>
    </tr>
</table>
<div id = "mydiv" style="width:100%;height=400;overflow=auto;">
<iframe name="summaryfrm" scrolling="no" frameborder="0" style="position:absolute; top:0px; left:0px; display:none;border:#909eff 1px solid;"></iframe>
<table id="tab" border="1" cellspacing="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" width="130%"  cellpadding="1" style="position:absolute;overflow:auto;">
<tr class="deepblue-left">
    <td width="1%"><%= label.getLabelName("L_Nummber") %></td>
    <td class="title_center" width="17%"><%= label.getLabelName("L_Hospital") %></td>
    <td class="title_center" width="9%"><%= label.getLabelName("L_DoctorCode") %></td>
    <td class="title_center" width="5%"><%= label.getLabelName("L_DoctorName") %></td>
    <td class="title_center" width="15%"><%= label.getLabelName("L_ProdName") %></td>
    <td class="title_center" width="7%"><%= label.getLabelName(" L_Salesqty") %></td>
    <td class="title_center" width="7%"><%= label.getLabelName("L_HospitalGrade") %></td>
    <td class="title_center" width="7%"><%= label.getLabelName("L_Departments") %></td>
	<td class="title_center" width="6%"><%= label.getLabelName("L_Spec") %></td>
    <td class="title_center" width="6%"><%= label.getLabelName("L_UnitPrice") %></td>
    <td class="title_center" width="7%"><%= label.getLabelName("L_ProductBusiness") %></td>
    <td class="title_center" width="8%"><%= label.getLabelName("L_Comments") %></td>
    <td class="title_center" width="8%"><%= label.getLabelName("L_CreateDate") %></td>
	<!--<td class="title_center" width="4%"><%= label.getLabelName("L_Status") %></td>-->
    <td width="1%">&nbsp;</td>
</tr>
<TBODY ID="oTBody">
<% 
	Integer Status;
	String statusStr = "";
	for(int i=0;i<j;i++){
	if(totalsummary.size()!=0){
		pageContext.setAttribute("onedetail",totalsummary.get(i));
		Status = (Integer)((HashMap)pageContext.getAttribute("onedetail")).get("status");
		statusStr = Status + ""; 
	}
	if((month.equals("1") || result.equals("true")) && periodflag.equals("true")){
%>
<tr id="tr<%=i%>" >
    <td><%=i+1%></td>
    <td>
        <div class="spellCode" style="z-index:<%= 4000 - i%>">
            <input type="text" name="spellitemcode<%=i%>" style="width:120px;" 
            <%if(totalsummary.size()!=0){%>
            	value="<custom:write name="onedetail" property="dealername" nbsp="true"/>" 
			<%}else{ %>
            	value="--助记码--" 
            <%} %>
            onfocus="javascript:clearQik(this,'助记码')" onblur="javascript:reQik(this,'助记码')">
            <div id="pharmacycodecontainer<%=i%>" class="container"></div>
        </div>
        <label style="width:120px">&nbsp;</label>
        <input type="text" name="pharmacycode<%=i%>" size='10' style="" onchange="page_getInfoByCode(this,1,<%=i%>)" 
        <%if(totalsummary.size()!=0){%>
        	value="<custom:write name="onedetail" property="dealercode"/>"
		<%}else{ %>
            	value="--快速代码--" 
        <%} %>
            onfocus="javascript:clearQik(this,'快速代码')" onblur="javascript:reQik(this,'快速代码')">
		<script>
            new Oval.SpellCodeAutoComplete({
                inputId: 'spellitemcode<%=i%>',
                containerId: 'pharmacycodecontainer<%=i%>',
                dataLoaderPagePath: "spellCodeDataLoader.jsp",
                maxResultsDisplayed: 10,
                queryType: 'hospital',
                minQueryStrLength: 2,
                itemPropertyNames: ['hospitalname','hospitalcode','hospitalid','hospitallevelname'],
                formatResult: function(itemProperties, queryString) {
                    var sMarkup = itemProperties[0];
                    return (sMarkup);
                },
                selectionChangeEventHandler: function(itemProperties) {
					document.cform.pharmacycode<%=i%>.value = itemProperties[1];					
					if(itemProperties[3]==undefined){itemProperties[3]="&nbsp;";}
					document.getElementById("tr<%=i%>").cells[6].innerHTML = "&nbsp;"+itemProperties[3];
					document.cform.dealerid<%=i%>.value = itemProperties[2];
					document.cform.dealercode<%=i%>.value = itemProperties[1];
					document.cform.dealername<%=i%>.value = itemProperties[0];
					document.cform.level<%=i%>.value = itemProperties[3];
					page_department(<%=i%>);
                }

            });
        </script>
        <a onclick="frm_select(this,1,<%=i%>)"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a>
    </td>
    <td>
		<input type="text" name="doccode<%=i%>"  size='10' style="" onchange="page_getInfoByCode(this,2,<%=i%>)" 
		<%if(totalsummary.size()!=0){%>
			value="<custom:write name="onedetail" property="doctorcode"/>"
		<%}else{ %>
            	value="--快速代码--" 
        <%} %>
            onfocus="javascript:clearQik(this,'快速代码')" onblur="javascript:reQik(this,'快速代码')">
            <a onclick="frm_select(this,2,<%=i%>)"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a></td>
    <td><custom:write name="onedetail" property="doctorname" nbsp="true"/></td>
	<td>
		<div class="spellCode" style="z-index:<%= 4000 - i%>">
            <input type="text" name="spellproditemcode<%=i%>" style="width:120px;" 
            <%if(totalsummary.size()!=0){%>
           		value="<custom:write name="onedetail" property="productname" nbsp="true"/>" 
            <%}else{%>
            	value="--助记码--" 
            <%}%>
            onfocus="javascript:clearQik(this,'助记码')" onblur="javascript:reQik(this,'助记码')">
            <div id="prodcodecontainer<%=i%>" class="container"></div>
        </div>
        <label style="width:120px">&nbsp;</label>
		<input type="text" name="prodcode<%=i%>" size='10' style="" onchange="page_getInfoByCode(this,3,<%=i%>)" 
		<%if(totalsummary.size()!=0){%>
			value="<custom:write name="onedetail" property="productcode"/>"
		<%}else{ %>
            	value="--快速代码--" 
        <%} %>
            onfocus="javascript:clearQik(this,'快速代码')" onblur="javascript:reQik(this,'快速代码')">
	<script>
            new Oval.SpellCodeAutoComplete({
                inputId: 'spellproditemcode<%=i%>',
                containerId: 'prodcodecontainer<%=i%>',
                dataLoaderPagePath: "spellCodeDataLoader.jsp",
                maxResultsDisplayed: 10,
                queryType: 'prod',
                minQueryStrLength: 2,
                itemPropertyNames: ['prodname','prodcode','prodid','unitprice','spec'],
                formatResult: function(itemProperties, queryString) {
                    var sMarkup = itemProperties[0];
                    return (sMarkup);
                },
                selectionChangeEventHandler: function(itemProperties) {
					if(itemProperties[4]==undefined){itemProperties[4]="&nbsp;";}
					document.getElementById("tr<%=i%>").cells[8].innerHTML = "&nbsp;"+itemProperties[4];
					if(itemProperties[3]==undefined){itemProperties[3]="&nbsp;";}
					document.getElementById("tr<%=i%>").cells[9].innerHTML = "&nbsp;"+itemProperties[3];
					document.cform.productid<%=i%>.value = itemProperties[2];
					document.cform.productcode<%=i%>.value = itemProperties[1];
					document.cform.productname<%=i%>.value = itemProperties[0];
					if(itemProperties[4]!="&nbsp;")
					document.cform.specifications<%=i%>.value = itemProperties[4];
					if(itemProperties[3]!="&nbsp;")
					document.cform.price<%=i%>.value = itemProperties[3];
					document.cform.prodcode<%=i%>.value = itemProperties[1];
					page_doSum(document.cform.price<%=i%>,<%=i%>);
                }

            });
        </script>
            <a onclick="frm_select(this,3,<%=i%>)"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a>
    </td>
	<td><input type="text" name="salesqty<%=i%>" size='8' value="<custom:write name="onedetail" property="salesqty"/>" onblur="page_doSum(this,<%=i%>)"/></td>
	<td><custom:write name="onedetail" property="level" nbsp="true"/></td>
	<td><custom:write name="onedetail" property="hosdeptname" nbsp="true"/></td>
	<td><custom:write name="onedetail" property="specifications" nbsp="true"/></td>
    <td><custom:write name="onedetail" property="price" nbsp="true"/></td>
    <td><custom:write name="onedetail" property="productgroupname" nbsp="true"/></td>
    <td><custom:text name="onedetail" property="description" size='15' colIndex="<%=new Integer(i)%>" /></td>
	<td><custom:write name="onedetail" property="createdate" nbsp="true"/></td>
	<!--<td><custom:write dictType="ZylStatus" name="onedetail" property="status" nbsp="true"/></td>-->
<%}else{%>
<tr id="tr<%=i%>" >
    <td><%=i+1%></td>
    <td><custom:write name="onedetail" property="dealercode" nbsp="true"/>&nbsp;
	<custom:write name="onedetail" property="dealername" nbsp="true"/></td>
    <td><custom:write name="onedetail" property="doctorcode" nbsp="true"/></td>
	<td><custom:write name="onedetail" property="doctorname" nbsp="true"/></td>
	<td><custom:write name="onedetail" property="productcode" nbsp="true"/>&nbsp;
	<custom:write name="onedetail" property="productname" nbsp="true"/></td>
	<td><custom:write name="onedetail" property="salesqty" nbsp="true"/></td>
	<td><custom:write name="onedetail" property="level" nbsp="true"/></td>
	<td><custom:write name="onedetail" property="hosdeptname" nbsp="true"/></td>
	<td><custom:write name="onedetail" property="specifications" nbsp="true"/></td>
    <td><custom:write name="onedetail" property="price" nbsp="true"/></td>
    <td><custom:write name="onedetail" property="productgroupname" nbsp="true"/></td>
    <td><custom:write name="onedetail" property="description" nbsp="true"/></td>
    <td><custom:write name="onedetail" property="createdate" nbsp="true"/></td>
    <!--<td><custom:write dictType="ZylStatus" name="onedetail" property="status" nbsp="true"/></td>-->
<%
}
if((month.equals("1") || result.equals("true")) && periodflag.equals("true")){
%>
	<td><a onclick="page_delOneDetail('<%=i%>',1)"><img src="<%=contextPath%>/images/cn/del1.gif" style="border:none"></a></td>
	<custom:hidden name="onedetail" property="tdr_formal_salesdataid" colIndex="<%= new Integer(i) %>"/>
	<custom:hidden name="onedetail" property="dealerid" colIndex="<%= new Integer(i) %>"/>
	<custom:hidden name="onedetail" property="dealercode" colIndex="<%= new Integer(i) %>"/>
	<custom:hidden name="onedetail" property="dealername" colIndex="<%= new Integer(i) %>" />
	<custom:hidden name="onedetail" property="level" colIndex="<%= new Integer(i) %>" />
	<custom:hidden name="onedetail" property="doctorid" colIndex="<%= new Integer(i) %>"/>
	<custom:hidden name="onedetail" property="doctorcode" colIndex="<%= new Integer(i) %>"/>
	<custom:hidden name="onedetail" property="doctorname" colIndex="<%= new Integer(i) %>" />
	<custom:hidden name="onedetail" property="hosdeptname" colIndex="<%= new Integer(i) %>" />
	<custom:hidden name="onedetail" property="productid" colIndex="<%= new Integer(i) %>"/>
	<custom:hidden name="onedetail" property="productcode" colIndex="<%= new Integer(i) %>"/>
	<custom:hidden name="onedetail" property="productname" colIndex="<%= new Integer(i) %>" />
	<custom:hidden name="onedetail" property="price" colIndex="<%= new Integer(i) %>"/>
	<custom:hidden name="onedetail" property="amount" colIndex="<%= new Integer(i) %>"/>
	<custom:hidden name="onedetail" property="specifications" colIndex="<%= new Integer(i) %>"/>
	<custom:hidden name="onedetail" property="deptcode" colIndex="<%=new Integer(i)%>"/>
	<custom:hidden name="onedetail" property="deptname" colIndex="<%=new Integer(i)%>"/>
	<custom:hidden name="onedetail" property="productgroupid" colIndex="<%=new Integer(i)%>"/>
	<custom:hidden name="onedetail" property="productgroupcode" colIndex="<%=new Integer(i)%>"/>
	<custom:hidden name="onedetail" property="productgroupname" colIndex="<%=new Integer(i)%>"/>
	<custom:hidden name="onedetail" property="status" value="10" colIndex="<%=new Integer(i)%>"/>
	
	<custom:hidden name="onedetail" property="year" value = "<%=year%>" colIndex="<%=new Integer(i)%>"/>
	<custom:hidden name="onedetail" property="month" value = "<%=month%>" colIndex="<%=new Integer(i)%>"/>
	<custom:hidden name="onedetail" property="businesstype" value = "170" colIndex="<%=new Integer(i)%>"/>
	<custom:hidden name="onedetail" property="maker" value = "<%=salesmanid%>" colIndex="<%=new Integer(i)%>"/>
	<custom:hidden name="onedetail" property="salesmanid" value = "<%=salesmanid%>" colIndex="<%=new Integer(i)%>"/>
	<custom:hidden name="onedetail" property="salesman" value = "<%=salesman%>" colIndex="<%=new Integer(i)%>"/>
	<custom:hidden name="onedetail" property="salesmanname" value = "<%=salesmanname%>" colIndex="<%=new Integer(i)%>"/>
	<custom:hidden name="onedetail" property="areacode" value = "<%=areacode%>" colIndex="<%=new Integer(i)%>"/>
	<custom:hidden name="onedetail" property="areaname" value = "<%=areaname%>" colIndex="<%=new Integer(i)%>"/>
	<custom:hidden name="onedetail" property="parentemployeeid" value = "<%=parentemployeeid%>" colIndex="<%=new Integer(i)%>"/>
	<custom:hidden name="onedetail" property="parentemployeecode" value = "<%=parentemployeecode%>" colIndex="<%=new Integer(i)%>"/>
	<custom:hidden name="onedetail" property="parentemployeename" value = "<%=parentemployeename%>" colIndex="<%=new Integer(i)%>"/>
	<custom:hidden name="onedetail" property="cityname" value = "<%=cityname%>" colIndex="<%=new Integer(i)%>"/>
	<custom:hidden name="onedetail" property="citycode" value = "<%=citycode%>" colIndex="<%=new Integer(i)%>"/>
	<custom:hidden name="onedetail" property="prarentareaname" value = "<%=parentareaname%>" colIndex="<%=new Integer(i)%>"/>
	<custom:hidden name="onedetail" property="prarentareacode" value = "<%=parentareacode%>" colIndex="<%=new Integer(i)%>"/>
	<custom:hidden name="onedetail" property="deptid" value = "<%=deptid%>" colIndex="<%=new Integer(i)%>"/>
	<custom:hidden name="onedetail" property="deptcode" value = "<%=deptcode%>" colIndex="<%=new Integer(i)%>"/>
	<custom:hidden name="onedetail" property="deptname" value = "<%=deptname%>" colIndex="<%=new Integer(i)%>"/>
	<%String dateStr = year+"-"+month+"-1";%>
	<custom:hidden name="onedetail" property="businessdate" value = "<%=dateStr%>" colIndex="<%=new Integer(i)%>"/>
<%}else{%>
	<td>&nbsp;</td>
<%}}%>
</tr>
</TBODY>
<tr>
    <td colspan="24" class="td_left">
    <%
		if((month.equals("1") || result.equals("true")) && periodflag.equals("true")){
	%>
        <a onclick="addNewRow(5);">
            <img src="<%=contextPath%>/images/cn/AddRow.gif" border="0">
        </a>
    <%}else{%>
    	&nbsp;
    <%}%>
    </td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</form>
<script langauge="javascript">
function addNewRow(num) {
    if (num == 0) return;
    var numrows = parseInt(document.getElementById("numrows").value);
    var oRow = oTBody.insertRow();
    for (j = 0; j < 13; j++)
    {
        oCell = oRow.insertCell();
        oCell.innerHTML = "&nbsp;";
    }
    oRow.id = "tr" + numrows;
    oRow.cells[0].innerHTML = oTBody.rows.length;
    var v_str = "<div class=\"spellCode\" style=\"z-index:" + (4000 - numrows) + "\">";
    v_str += "<input type=\"text\" name=\"spellitemcode" + numrows + "\" style=\"width:120px;\" value=\"--助记码--\" onfocus=\"javascript:clearQik(this,'助记码')\" onblur=\"javascript:reQik(this,'助记码')\">";
    v_str += "<div id=\"pharmacycodecontainer" + numrows + "\" class=\"container\"></div>";
    oRow.cells[1].innerHTML = v_str + "</div>";
    oRow.cells[1].innerHTML += "<label style='width:120px'>&nbsp;</label>&nbsp;";
    oRow.cells[1].innerHTML += "<input type=\"text\" name=\"pharmacycode" + numrows + "\"  size='10'  onchange=\"page_getInfoByCode(this,1," + numrows + ")\" value=\"--快速代码--\"  style=\"\" onfocus=\"javascript:clearQik(this,'快速代码')\" onblur=\"javascript:reQik(this,'快速代码')\"/>&nbsp;";
    oRow.cells[1].innerHTML += "<a onclick=\"frm_select(this,1," + numrows + ")\"><input type=\"button\" class=\"button3\" imgsrc=\"flash.gif\" border=\"0\" value=\"*\"/></a>";
    oRow.cells[2].innerHTML = "<input type=\"text\" name=\"doccode" + numrows + "\"  size='10'  onchange=\"page_getInfoByCode(this,2," + numrows + ")\" value=\"--快速代码--\"  style=\"\" onfocus=\"javascript:clearQik(this,'快速代码')\" onblur=\"javascript:reQik(this,'快速代码')\"/>&nbsp;";
    oRow.cells[2].innerHTML += "<a onclick=\"frm_select(this,2," + numrows + ")\"><input type=\"button\" class=\"button3\" imgsrc=\"flash.gif\" border=\"0\" value=\"*\"/></a>";
	v_str = "<div class=\"spellCode\" style=\"z-index:" + (4000 - numrows) + "\">";
    v_str += "<input type=\"text\" name=\"spellproditemcode" + numrows + "\" style=\"width:120px;\" value=\"--助记码--\" onfocus=\"javascript:clearQik(this,'助记码')\" onblur=\"javascript:reQik(this,'助记码')\">";
    v_str += "<div id=\"prodcodecontainer" + numrows + "\" class=\"container\"></div>";
    oRow.cells[4].innerHTML = v_str + "</div>";
    oRow.cells[4].innerHTML += "<label style='width:120px'>&nbsp;</label>&nbsp;";
    oRow.cells[4].innerHTML += "<input type=\"text\" name=\"prodcode" + numrows + "\"  size='10'  onchange=\"page_getInfoByCode(this,3," + numrows + ")\" value=\"--快速代码--\" style=\"\" onfocus=\"javascript:clearQik(this,'快速代码')\" onblur=\"javascript:reQik(this,'快速代码')\"/>&nbsp;";
    oRow.cells[4].innerHTML += "<a onclick=\"frm_select(this,3," + numrows + ")\"><input type=\"button\" class=\"button3\" imgsrc=\"flash.gif\" border=\"0\" value=\"*\"/></a>";
	oRow.cells[5].innerHTML = "<input type=\"text\" name=\"salesqty"+numrows+"\" size='8' onblur=\"page_doSum(this,"+numrows+")\"/>";
	oRow.cells[11].innerHTML = "<input type=\"text\" name=\"description"+numrows+"\" size='15'/>";
	oRow.cells[12].innerHTML = "<a onclick=\"page_delOneDetail('" + numrows + "');\"><img src='<%=contextPath%>/images/cn/del1.gif' style='border:none'></a>";
	oRow.cells[12].innerHTML += "<input type=\"hidden\" name=\"dealerid"+numrows+"\"/>";
	oRow.cells[12].innerHTML += "<input type=\"hidden\" name=\"dealername"+numrows+"\"/>";
	oRow.cells[12].innerHTML += "<input type=\"hidden\" name=\"dealercode"+numrows+"\"/>";
	oRow.cells[12].innerHTML += "<input type=\"hidden\" name=\"level"+numrows+"\"/>";
	oRow.cells[12].innerHTML += "<input type=\"hidden\" name=\"doctorid"+numrows+"\"/>";
	oRow.cells[12].innerHTML += "<input type=\"hidden\" name=\"doctorcode"+numrows+"\"/>";
	oRow.cells[12].innerHTML += "<input type=\"hidden\" name=\"doctorname"+numrows+"\"/>";
	oRow.cells[12].innerHTML += "<input type=\"hidden\" name=\"hosdeptname"+numrows+"\"/>";
	oRow.cells[12].innerHTML += "<input type=\"hidden\" name=\"productid"+numrows+"\"/>";
	oRow.cells[12].innerHTML += "<input type=\"hidden\" name=\"productcode"+numrows+"\"/>";
	oRow.cells[12].innerHTML += "<input type=\"hidden\" name=\"productname"+numrows+"\"/>";
	oRow.cells[12].innerHTML += "<input type=\"hidden\" name=\"price"+numrows+"\"/>";
	oRow.cells[12].innerHTML += "<input type=\"hidden\" name=\"amount"+numrows+"\"/>";
	oRow.cells[12].innerHTML += "<input type=\"hidden\" name=\"specifications"+numrows+"\"/>";
	oRow.cells[12].innerHTML += "<input type=\"hidden\" name=\"productgroupid"+numrows+"\"/>";
	oRow.cells[12].innerHTML += "<input type=\"hidden\" name=\"productgroupcode"+numrows+"\"/>";
	oRow.cells[12].innerHTML += "<input type=\"hidden\" name=\"productgroupname"+numrows+"\"/>";
	
	oRow.cells[12].innerHTML += "<input type=\"hidden\" name=\"year"+numrows+"\" value=\"<%=year%>\"/> ";
	oRow.cells[12].innerHTML += "<input type=\"hidden\" name=\"month"+numrows+"\" value=\"<%=month%>\"/>";
	oRow.cells[12].innerHTML += "<input type=\"hidden\" name=\"businesstype"+numrows+"\" value=\"170\"/>";
	oRow.cells[12].innerHTML += "<input type=\"hidden\" name=\"maker"+numrows+"\" value=\"<%=salesmanid%>\"/>";
	oRow.cells[12].innerHTML += "<input type=\"hidden\" name=\"salesmanid"+numrows+"\" value=\"<%=salesmanid%>\"/>";
	oRow.cells[12].innerHTML += "<input type=\"hidden\" name=\"salesman"+numrows+"\" value=\"<%=salesman%>\"/>";
	oRow.cells[12].innerHTML += "<input type=\"hidden\" name=\"salesmanname"+numrows+"\" value=\"<%=salesmanname%>\"/>";
	oRow.cells[12].innerHTML += "<input type=\"hidden\" name=\"areacode"+numrows+"\" value=\"<%=areacode%>\"/>";
	oRow.cells[12].innerHTML += "<input type=\"hidden\" name=\"areaname"+numrows+"\" value=\"<%=areaname%>\"/>";
	oRow.cells[12].innerHTML += "<input type=\"hidden\" name=\"parentemployeeid"+numrows+"\" value=\"<%=parentemployeeid%>\"/>";
	oRow.cells[12].innerHTML += "<input type=\"hidden\" name=\"parentemployeecode"+numrows+"\" value=\"<%=parentemployeecode%>\"/>";
	oRow.cells[12].innerHTML += "<input type=\"hidden\" name=\"parentemployeename"+numrows+"\" value=\"<%=parentemployeename%>\"/>";
	oRow.cells[12].innerHTML += "<input type=\"hidden\" name=\"prarentareaname"+numrows+"\" value=\"<%=parentareaname%>\"/>";
	oRow.cells[12].innerHTML += "<input type=\"hidden\" name=\"prarentareacode"+numrows+"\" value=\"<%=parentareacode%>\"/>";
	oRow.cells[12].innerHTML += "<input type=\"hidden\" name=\"deptid"+numrows+"\" value=\"<%=deptid%>\"/>";
	oRow.cells[12].innerHTML += "<input type=\"hidden\" name=\"deptname"+numrows+"\" value=\"<%=deptname%>\"/>";
	oRow.cells[12].innerHTML += "<input type=\"hidden\" name=\"deptcode"+numrows+"\" value=\"<%=deptcode%>\"/>";
	oRow.cells[12].innerHTML += "<input type=\"hidden\" name=\"cityname"+numrows+"\" value=\"<%=cityname%>\"/>";
	oRow.cells[12].innerHTML += "<input type=\"hidden\" name=\"citycode"+numrows+"\" value=\"<%=citycode%>\"/>";
	oRow.cells[12].innerHTML += "<input type=\"hidden\" name=\"businessdate"+numrows+"\" value=\"<%=year+"-"+month+"-1"%>\"/>";
	oRow.cells[12].innerHTML += "<input type=\"hidden\" name=\"status"+numrows+"\" value=\"10\"/>";
	new Oval.SpellCodeAutoComplete({
                inputId: 'spellitemcode'+ numrows,
                containerId: 'pharmacycodecontainer'+ numrows,
                dataLoaderPagePath: "spellCodeDataLoader.jsp",
                maxResultsDisplayed: 10,
                queryType: 'hospital',
                minQueryStrLength: 2,
                itemPropertyNames: ['hospitalname','hospitalcode','hospitalid','hospitallevelname'],
                formatResult: function(itemProperties, queryString) {
                    var sMarkup = itemProperties[0];
                    return (sMarkup);
                },
                selectionChangeEventHandler: function(itemProperties) {
					eval("document.cform.pharmacycode"+ numrows).value = itemProperties[1];					
					document.getElementById("tr"+ numrows).cells[6].innerHTML = "&nbsp;"+itemProperties[3];
					eval("document.cform.dealerid"+ numrows).value = itemProperties[2];
					eval("document.cform.dealercode"+ numrows).value = itemProperties[1];
					eval("document.cform.dealername"+ numrows).value = itemProperties[0];
					eval("document.cform.level"+ numrows).value = itemProperties[3];
					page_department(numrows);
                }

            });
	new Oval.SpellCodeAutoComplete({
                inputId: 'spellproditemcode'+ numrows,
                containerId: 'prodcodecontainer'+ numrows,
                dataLoaderPagePath: "spellCodeDataLoader.jsp",
                maxResultsDisplayed: 10,
                queryType: 'prod',
                minQueryStrLength: 2,
                itemPropertyNames: ['prodname','prodcode','prodid','unitprice','spec'],
                formatResult: function(itemProperties, queryString) {
                    var sMarkup = itemProperties[0];
                    return (sMarkup);
                },
                selectionChangeEventHandler: function(itemProperties) {
					document.getElementById("tr" + numrows).cells[8].innerHTML = "&nbsp;"+itemProperties[4];
					document.getElementById("tr" + numrows).cells[9].innerHTML = "&nbsp;"+itemProperties[3];
					eval("document.cform.productid" + numrows).value = itemProperties[2];
					eval("document.cform.productcode" + numrows).value = itemProperties[1];
					eval("document.cform.productname" + numrows).value = itemProperties[0];
					eval("document.cform.specifications" + numrows).value = itemProperties[4];
					eval("document.cform.price" + numrows).value = itemProperties[3];
					eval("document.cform.prodcode" + numrows).value = itemProperties[1];
					page_doSum(eval("document.cform.price" + numrows),numrows);
					page_department(numrows);
                }

            });
    document.getElementById("numrows").value = numrows + 1;
    addNewRow(num - 1);
}
<%	if(detail.size()!=0){%>
//alert("医生处方量已成功提交，<%=year%>年<%=month%>月的上报处方量不能再次修改！");
<%}%>
</script>
</script>
<iframe id="dataLoaderIframe" style="display:none;z-index:5000"></iframe>
</body>
</html>